const { DataTypes } = require("sequelize");
const sequelize = require("../dbConnect");

const Article = sequelize.define(
  "article",
  {
    title: {
      type: DataTypes.STRING(20),
      allowNull: false,
    },
    description: {
      type: DataTypes.STRING,
    },
    toc: {
      type: DataTypes.JSON,
      allowNull: false,
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: false,
    },
    thumb: {
      type: DataTypes.INTEGER,
    },
    scanNumber: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
    },
    commentNumber: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
    },
  },
  {
    freezeTableName: true,
  }
);

module.exports = Article;
